package com.primb.bench.project.search.fragment;


import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.primb.bench.R;
import com.primb.bench.base.BaseFragment;
import com.primb.bench.common.constant.AppConstant;
import com.primb.bench.common.utils.RoleLevelConvert;
import com.primb.bench.project.search.activity.SearchPriceActivity;
import com.primb.bench.project.search.activity.SearchReapplyActivity;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * Created by Chen on 2017/4/17.
 * 功能描述：
 */

public class IndexFragment extends BaseFragment {

    @BindView(R.id.tv_search_title)
    TextView tvSearchTitle;

    @Override
    protected int onBaseLayoutId() {
        return R.layout.fragment_index;
    }

    @Override
    protected void onBaseBindView() {
        int statusBarHeight = -1;
        //获取status_bar_height资源的ID
        int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
        if (resourceId > 0) {
            //根据资源ID获取响应的尺寸值
            statusBarHeight = getResources().getDimensionPixelSize(resourceId);
            RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
            layoutParams.setMargins(0, statusBarHeight + 12, 0, 0);
//            tvApprovalTitle.setTextSize(18);
            tvSearchTitle.setLayoutParams(layoutParams);
        }
    }

    @Override
    protected void onBaseLoadData() {

    }

    @OnClick({R.id.tv_search_pricing, R.id.tv_search_promise})
    public void onViewClicked(View view) {
        Intent intent = new Intent();
        switch (view.getId()) {
            case R.id.tv_search_pricing:
                intent.setClass(getContext(), SearchPriceActivity.class);
                startActivity(intent);
                break;
            case R.id.tv_search_promise:
                if (AppConstant.ROLE_LEVEL_ENUM == RoleLevelConvert.RoleLevel.MANAGER) {
                    intent.setClass(getContext(), SearchReapplyActivity.class);
                    startActivity(intent);
                } else {
                    showAlterDialogOne("提示", "抱歉，此功能不在您的权限范围");
                }
                break;
        }
    }
}
